package ch06.d2;

import java.util.Scanner;

public class Account {
    private String name;//用户名
    private String account;//账号
    private String pwd;//密码
    private double balance;//余额


    public Account(String name, String account, String pwd, double balance) {
        this.name = name;
        this.account = account;
        this.pwd = pwd;
        this.balance = balance;
    }


    public void login() {
        System.out.println("欢迎光临");
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入账号：");
        String account = scan.next();
        System.out.println("请输入密码：");
        String pwd = scan.next();

        if (this.account.equals(account) && this.pwd.equals(pwd)) {
            System.out.println("登录成功");
            this.operate();
        } else {
            System.out.println("登录失败");
            login();
        }


    }

    //登录成功后的操作
    private void operate() {
        System.out.println("请选择操作：");
        System.out.println("1.存款");
        System.out.println("2.取款");
        System.out.println("3.查询余额");
        System.out.println("4.退出");
        Scanner scan = new Scanner(System.in);
        int choice = scan.nextInt();
        switch (choice) {
            case 1:
                saveMoney();
                break;
            case 2:
                drawMoney();
                break;
            case 3:
                queryBalance();
                break;
            case 4:
                System.out.println("谢谢使用");
                System.exit(0);
                break;
            default:
                System.out.println("输入错误，请重新输入");
                operate();
                break;

        }
        operate();
    }

    private void drawMoney() {
    }

    private void queryBalance() {
        
    }

    private void saveMoney() {
    }


}
